﻿Imports BLL
Imports DevComponents.DotNetBar

Public Class Form1
    Dim dattieccuoi As DatTiecCuoiConTrol
    Dim danhsachtieccuoi As DanhSachTiecCuoiConTrol
    Dim baocao As BaoCaoConTrol
    Dim quydinh As QuyDinhConTrol
    Dim datsanh As DatSanhConTrol




    Private Sub biDatTiecCuoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles biDatTiecCuoi.Click
        pnMain.Controls.Clear()
        If dattieccuoi Is Nothing Then dattieccuoi = New DatTiecCuoiConTrol
        pnMain.Controls.Add(dattieccuoi)
    End Sub

    Private Sub biDanhSachTiecCuoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles biDanhSachTiecCuoi.Click
        pnMain.Controls.Clear()
        If danhsachtieccuoi Is Nothing Then danhsachtieccuoi = New DanhSachTiecCuoiConTrol
        pnMain.Controls.Add(danhsachtieccuoi)
    End Sub


    Private Sub biBaoCao_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles biBaoCao.Click
        pnMain.Controls.Clear()
        If baocao Is Nothing Then baocao = New BaoCaoConTrol
        pnMain.Controls.Add(baocao)
    End Sub

    Private Sub biQuyDinh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles biQuyDinh.Click
        pnMain.Controls.Clear()
        If quydinh Is Nothing Then quydinh = New QuyDinhConTrol
        pnMain.Controls.Add(quydinh)
    End Sub

    Private Sub biDatSanh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        pnMain.Controls.Clear()
        If datsanh Is Nothing Then datsanh = New DatSanhConTrol
        pnMain.Controls.Add(datsanh)
    End Sub


    Private Sub biLuuTiecCuoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles biLuuTiecCuoi.Click
        Try
            'Luu tiec cuoi
            Dim tieccuoidto As New TiecCuoi()
            tieccuoidto.ID = Convert.ToInt32(dattieccuoi.txtMaTiecCuoi.Text)
            tieccuoidto.TenChuRe = dattieccuoi.txtTenChuRe.Text
            tieccuoidto.TenCoDau = dattieccuoi.txtTenCoDau.Text
            tieccuoidto.DienThoai = dattieccuoi.txtDienThoai.Text
            tieccuoidto.Ngay = dattieccuoi.dtiNgay.Value
            tieccuoidto.Ca = dattieccuoi.cbThoiGian.SelectedItem.ToString()
            tieccuoidto.TienDatCoc = dattieccuoi.nuTienDatCoc.Value
            tieccuoidto.SoBanDuTru = dattieccuoi.nuSoBanDuTru.Value
            tieccuoidto.SoLuongBan = dattieccuoi.nuSoLuongBan.Value
            tieccuoidto.Sanh = dattieccuoi.cbSanh.SelectedValue

            Dim tieccuoibus As New TiecCuoi_BLL()
            
            tieccuoibus.Them(tieccuoidto)


            'Luu mon an
            For Each MonAn As MonAn In dattieccuoi.ds_monAn
                Dim monAnDat As New MonAnDat()
                Dim monAnDat_BLL As New MonAnDuocDat_BLL()
                monAnDat.MonAn = MonAn.ID
                monAnDat.TiecCuoi = Convert.ToInt32(dattieccuoi.txtMaTiecCuoi.Text)
                monAnDat_BLL.Them(monAnDat)
            Next

            'Luu mon an
            For Each DichVu As DichVu In dattieccuoi.ds_dichVu
                Dim dichVuDat As New DichVuDat()
                Dim dichVuDat_BLL As New DichVuDuocDat_BLL()
                dichVuDat.DichVu = DichVu.ID
                dichVuDat.TiecCuoi = Convert.ToInt32(dattieccuoi.txtMaTiecCuoi.Text)
                dichVuDat_BLL.Them(dichVuDat)
            Next

            MessageBox.Show("Lưu thành công !", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        Catch ex As Exception
            MessageBox.Show("Lưu thất bại !" + vbNewLine + ex.Message, "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try
    End Sub

    Private Sub ButtonItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem7.Click
        Me.Close()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ButtonItem1.Text = RibbonTabItem1.Text
    End Sub

    Private Sub RibbonTabItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RibbonTabItem1.Click
        ButtonItem1.Text = RibbonTabItem1.Text
    End Sub

    Private Sub RibbonTabItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RibbonTabItem2.Click
        ButtonItem1.Text = RibbonTabItem2.Text
    End Sub

    Private Sub RibbonTabItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RibbonTabItem3.Click
        ButtonItem1.Text = RibbonTabItem3.Text
    End Sub

    Private Sub RibbonTabItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RibbonTabItem4.Click
        ButtonItem1.Text = RibbonTabItem4.Text
    End Sub

    

    Private Sub ButtonItem16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem16.Click
        dattieccuoi.LamLai()
    End Sub

    Private Sub ButtonItem17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem17.Click
        dattieccuoi.LoadDuLieu()
    End Sub
End Class
